#include <iostream>
using namespace std;

int main()
{
    int T;
    int n;
    cin >>T;
    for(int i = 0; i<T; i++)
    {
        cin>>n;
        int * p = new int[n];
        int sum = 0;
        for(int j=0; j<n; j++)
        {
            cin>>*(p+j);
            sum = sum + *(p+j);
        }
        int num = 0;
        sum = (double)sum/n;
        for(int j=0; j<n; j++)
        {
            if(*(p+j)>sum)
                num++;
        }
        cout<<num<<endl;
        delete []p;
        
        
    }
    
}